package com.bridgeintelligent.tag.customer.service;

import com.alibaba.fastjson.JSONObject;
import com.bridgeintelligent.tag.customer.entity.CustomersPage;
import com.bridgeintelligent.tag.customer.entity.Result;
import com.bridgeintelligent.tag.customer.entity.ShareRelation;
import com.bridgeintelligent.tag.customer.model.ShareModel;
import com.bridgeintelligent.tag.customer.pojo.*;
import com.bridgeintelligent.tag.customer.vo.TagCustomersVO;

import java.util.List;

/**
 * 客群服务层接口
 */
public interface CustomersService {

    /**
     * 校验客群名是否重复
     *
     * @param coustomersName
     * @return
     */
    boolean checkCustomersName(String coustomersName);

    /**
     * 根据客群id查找客群名称
     *
     * @param coustomersId
     * @return
     */
    String findCustomersNameById(String coustomersId);

    /**
     * 获取客群列表
     *
     * @param model 查询
     * @return 结果
     */
    Result list(ListQueryModel model);

    /**
     * 查看某个索引下的客群列表
     * @param indexId
     * @return
     */
    Result indexCustomerList(String indexId,String customersName);

    /**
     * 获取渠道列表
     *
     * @return
     */
    List<Channel> findAllChannel();


    /**
     * 新增客群
     */
    void addCustomers(CustomersModel customersModel);

    /**
     * 新建并发布
     * @param customersName
     * @param customersDes
     * @param dateType
     * @param shareChannelIds
     * @param queryCriteria
     * @return
     */
    default Customers addAndDeployCustomers(String customersName, String customersDes, String dateType,
                                            String[] shareChannelIds, JSONObject queryCriteria){
        return null;
    }

    /**
     * 查询客户数
     * @param customers
     * @param queryModel
     */
    void getCountAmount(Customers customers, QueryModel queryModel);

    /**
     * 删除客群
     *
     * @param customersId
     */
    void delCustomers(String customersId);

    /**
     * 逻辑删除
     *
     * @param customersId
     */
    default void deleteInPage(String customersId){}

    /**
     * 修改客群
     *
     * @param customersId
     * @param customersName
     * @param customersDes
     * @param status
     * @param shareChannelIds
     * @param queryCriteria
     */
    void updateCustomers(String customersId, String customersName, String customersDes, String dateType,String status, String[] shareChannelIds, JSONObject queryCriteria,String index);

    /**
     * 查询单个客群详细信息
     *
     * @param customersId
     * @return
     */
    Customers findOneById(String customersId);

    /**
     * 获取我的列表
     *
     * @param pageNumber
     * @param pageSize
     * @param customersName
     * @param status
     * @param createTimeStart
     * @param createTimeEnd
     * @param uptTimeStart
     * @param uptTimeEnd
     * @return
     */
    Result myList(Integer pageNumber, Integer pageSize, String customersName, String status, String createTimeStart, String createTimeEnd, String uptTimeStart, String uptTimeEnd,String dateType);

    //查询条件组
    List<FilterGroup> findFilterGroup(String parentId, String customersId, List<Filter> filters);

    /**
     * 根据dimId查找客群Ids
     *
     * @param dimId
     * @return
     */
    List<String> findCustomersIdsByDimId(String dimId);

    /**
     * 根据关键词搜索
     * @param key
     * @return
     */
    default List<TagCustomersVO> getListByName(String key, long amount){
        return null;
    }

    /**
     * 取消关联状态
     * @param customersId
     */
    default int unRelated(String customersId){
        return 0;
    }

    /**
     * 关联
     * @param customersId
     */
    default int related(String customersId){
        return 0;
    }


    /**
     * 获取发布的客群和有关联种子客群的
     * @param page
     * @param size
     * @return
     */
    CustomersPage<Customers> getDeployAndSeedCustomersByPage(int page, int size);

    /**
     * 更新
     * @param customers
     * @return
     */
    int update(Customers customers);

    /**
     * 共享列表
     * @param model
     * @return
     */
    Result sharedList(ListQueryModel model);

    /**
     * 私有列表
     * @param model
     * @return
     */
    Result privateList(ListQueryModel model);

    /**
     * 共享
     * @param shareModel
     * @throws Exception
     */
    void give(ShareModel shareModel);

    /**
     * 共享列表
     * @param shareModel
     * @throws Exception
     */
    CustomersPage<ShareRelation> getShareList(ShareListQueryModel shareModel);

    /**
     * 共享信息
     * @param customersId
     * @return
     */
    ShareModel sharedInfo(String customersId);
}
